<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator"%>
<%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="pages"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

	<jsp:include page="../_includes/projectDataGrid.jsp" />

	<div id="dataDiv" style="overflow hidden;" >
		<table id="dataTable" class="expireHandler"></table>
	</div>

	<script type="text/javascript">
		var dataTableInitied = false;

		jQuery("#dataTable").bind("expiredShow", function() {
			var expired = jQuery(expiredObjects).attr(this.id) == null ? true : false;
			if(!expired) { 
				console.log("%s: %o", "Not expired at dataTable - ajaxShowProjects", this);
				return;
			} 
			jQuery(expiredObjects).attr(this.id,false);

			if(!dataTableInitied) {
				console.log("%s: %o", "Creating dataTable - ajaxShowProjects", this);
				jQuery("#dataTable").jqGrid({
					datatype: 'json',
					url: 'project/jsonShowProjects?projectNumber=' + state.projectNumber + '&columns=${dataGrid.cols}', 
				    colNames:${dataGrid.colNames},
				    colModel :${dataGrid.colModel},
				    sortname: 'number',
				    sortorder: "desc",
				    imgpath: 'themes/basic/images',
				    scrollOffset: 0,
				    width: 650,
				    autoheight: true,
				    shrinkToFit:false,
				    autowidth: true,
					loadComplete: function() {
						if(jQuery("#dataTable").getGridParam('userData').parent != null) {
				    		jQuery("#dataTable").addRowData( jQuery("#dataTable").getGridParam('userData').parent.id, {"number": "<s:text name='project.upOneLevel' />", emptyFlag: true}, "first");
						}
						dataTableInitied = true;
			    	},
			    	onSelectRow: function(id){
				    	window.location.hash="#projectNumber="+id;
			    	}
				});
			} else {
				jQuery("#dataTable").jqGrid('setGridParam',{url:'project/jsonShowProjects?projectNumber=' + state.projectNumber + '&columns=${dataGrid.cols}'}).trigger("reloadGrid");
			}
		});
	</script>
